package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.system.domain.ProjectTrack;
import com.ruoyi.system.mapper.ProjectTrackMapper;
import com.ruoyi.system.service.IProjectTrackService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ProjectTrackServiceImpl implements IProjectTrackService {

    @Resource
    private ProjectTrackMapper projectTrackMapper;

    @Override
    public int add(ProjectTrack track) {
        return projectTrackMapper.insert(track);
    }

    @Override
    public int update(ProjectTrack track) {
        return projectTrackMapper.updateById(track);
    }

    @Override
    public int deleteById(Long id) {
        return projectTrackMapper.deleteById(id);
    }

    @Override
    public ProjectTrack getById(Long id) {
        return projectTrackMapper.selectById(id);
    }

    @Override
    public List<ProjectTrack> listByProjectId(Long projectId) {
        return projectTrackMapper.selectList(new LambdaQueryWrapper<ProjectTrack>()
                .eq(ProjectTrack::getProjectId, projectId)
                .eq(ProjectTrack::getDeleted, 0)
                .orderByDesc(ProjectTrack::getTrackTime)
                .orderByDesc(ProjectTrack::getId));
    }
}


